﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace NetOpen_System.Component
{
    /// <summary>
    /// ExcludeUserAgent匹配引擎
    /// </summary>
    public sealed class ExcludeUserAgentMatchEngine
    {

        private List<ExcludeUserAgent> m_ExcludeUserAgentList = new List<ExcludeUserAgent>();
       

        public ExcludeUserAgentMatchEngine(XmlNode node)
        {
            ParseFromNode(node);
        }

        private void ParseFromNode(XmlNode node)
        {
            if (node == null || !node.HasChildNodes)
                return;

            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.Name == "add")
                    AppendNode(n);
                

            }

        }

        private void AppendNode(XmlNode node)
        {
            XmlAttributeReader attReader = new XmlAttributeReader(node.Attributes);
            string keyword = attReader.GetString("keyword", "");

            ExcludeUserAgent excludeuseragent = new ExcludeUserAgent();

            excludeuseragent.keyword = keyword;

            m_ExcludeUserAgentList.Add(excludeuseragent);
        }


        public List<ExcludeUserAgent> ExcludeUserAgentList
        {
            get { return m_ExcludeUserAgentList; }
        }
    }
}
